<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <?php include 'inc/head.php'; ?>
</head>

<body>
  <?php include 'inc/header.php'; ?>

  <div class="container">

    <table class="table table-sm table-bordered table-hover">
      <thead class="bg-light">
        <tr>
          <th>ID</th>
          <th>帐号</th>
          <th>备注</th>
          <th>状态</th>
          <th>管理</th>
        </tr>
      </thead>
      <tbody>
        <?php
        foreach ($list as $row) {
          echo '<tr><td>' . $row['id'] . '</td><td>' . $row['u_name'] . '</td><td>' . $row['u_tname'] . '</td><td>' . ($row['u_enable'] ? '<span class="badge bg-success">生效</span>' : '<span class="badge bg-danger">失效</span>') . '</td><td><a href="' . M('admin', 'admin', 'edit', $row['id']) . '">编辑</a> <a href="' . M('admin', 'admin', 'del', $row['id']) . '" class="' . (1 == $row['id'] ? 'invisible' : '') . '" onclick="return confirm(\'确认要删除吗？\')">删除</a></td></tr>';
        }
        ?>
      </tbody>
    </table>
    <nav>
      <ul class="pagination pagination-sm justify-content-center"><?php echo $pager->show(); ?></ul>
    </nav>

    <?php
    echo form_create(
      ['action' => M('admin', 'admin', 'add')],
      [
        ['type' => 'text', 'label' => '登录账号', 'key' => 'u_name', 'required' => 'required'],
        ['type' => 'password', 'label' => '登录密码', 'key' => 'u_psw', 'placeholder' => '8-16位字符，包含大写字母，小写字母，数字及特殊符号中的3种', 'required' => 'required'],
        ['type' => 'password', 'label' => '效验密码', 'key' => 'u_psw_confirm', 'required' => 'required'],
        ['type' => 'text', 'label' => '备注', 'key' => 'u_tname'],
        ['type' => 'select', 'label' => '权限角色', 'key' => 'u_rid', 'value' => $list_role],
        ['type' => 'submit', 'label' => '提交', 'key' => 'save']
      ],
      ['管理员新增']
    );
    ?>

  </div>
  <?php include 'inc/footer.php'; ?>
</body>

</html>